package com.gome.splunk.DataBase;

import android.database.sqlite.SQLiteOpenHelper;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


/**
 * Created by i.Recall_Star on 2017/5/8.
 */

public class CustomDBHelper extends SQLiteOpenHelper {
    private static final int DB_VERSION = 1;
    private static final String DB_NAME = "Splunk.db";
    public static final String TABLE_NAME = "ErrorInfo";
    public CustomDBHelper(Context context){
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        // create table NetworkType:当前网络类型  Operators:运营商  RequestTime:请求时间  ResponseCode:响应编码  ErrorMessage:错误信息  RUL:请求 URL  IsUploading:是否完成上传（主要为上传错误信息的标示 1:已上传  0:未上传）
        String sql = "create table if not exists " + TABLE_NAME + " (id integer primary key, networkType text, operators text, requestTime text, responseCode integer, errorMessage text, RUL text, isUploading text, systemVersion text, systemType text, IMEI text, userName text)";
        sqLiteDatabase.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
        String sql = "DROP TABLE IF EXISTS " + TABLE_NAME;
        sqLiteDatabase.execSQL(sql);
        onCreate(sqLiteDatabase);
    }
}
